package com.example.testapplication;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {
	
	protected CustomApplication app;
	protected Intent intent;
	
	public EditText email;
	public EditText name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        email = (EditText) findViewById(R.id.email_value);
		name = (EditText) findViewById(R.id.name_value);
		
		Button sendButton = (Button)findViewById(R.id.submit);
		sendButton.setOnClickListener(sendListener);
		
		// Get the application instance
		app = (CustomApplication)getApplication();
		intent = new Intent(this, UserActivity.class);
    }

    private OnClickListener sendListener = new OnClickListener() {
		
		public void onClick(View v) {
		
			String email_str = email.getText().toString();
			String name_str = name.getText().toString();
			app.setUser(new UserModel(name_str, email_str));
			startActivity(intent);
		}
	};
    
}
